<!-- 百人&棋牌(飞机) -->
<template>
  <el-dialog v-if="props.show" :model-value="props.show" :title="'【百人场】'+data.game_name" top="8vh" width="60%" @close="onHideDetails" 
    :close-on-press-escape="false" :destroy-on-close="true" :close-on-click-modal="false">
    <div v-loading="indexStore.moduleLoading">
      <form-item title="游戏名称" value="game_name">
        <GameHeaderInfo :game_id="props.checkedItem.game_id" />
      </form-item>
      <div v-if="!indexStore.is_general_agent" class="dialogMaxHeight" :class="props.isDisableUser ? 'disableUser' : ''">
        <el-form ref="ruleFormRef" :model="data" :inline="true" :rules="rules" :scroll-to-error="true">
          <form-item title="商户" :pass="true" value="agent_id" v-show="data.agent_id">
            <el-select v-model="data.agent_id" placeholder="请选择" filterable @change="chooseOperator">
              <el-option v-for="item in indexStore.agentArray" :key="item.value"
                :label="'【' + item.value + '】' + item.label" :value="item.value" />
            </el-select>
          </form-item>
          <form-item title="游戏水位" :pass="true" value="pool" v-show="data.agent_id">
            <div class="flexWarp">
              <span class="margin5" v-for="(item,index) in data.serverPoolList" :key="index">
                <el-tag type="danger">{{ item.label }}</el-tag>：
                <el-input-number v-model="item.value" :min="-99999999999999999999" :max="99999999999999999999" :precision="0"
                  placeholder="游戏水位" clearable controls-position="right" />
              </span>
            </div>
          </form-item>
          <form-item title="房间最大人数" :pass="true" value="a_hundred_num">
            <el-input-number v-model="data.a_hundred_num" :min="0" :max="99999999999999999999" :precision="0"
              placeholder="房间最大人数" clearable controls-position="right" />
          </form-item>
          <form-item title="抽水比例" :pass="true" value="a_hundred_pump">
            <el-input-number v-model="data.a_hundred_pump" :min="0" :max="100" :precision="4" placeholder="抽水比例" clearable
              controls-position="right" />%
          </form-item>
          <form-item title="利润率" :pass="true" value="a_hundred_profitmargin">
            <el-input-number v-model="data.a_hundred_other_details.a_hundred_profitmargin" :min="0" :max="100"
              :precision="0" placeholder="利润率" clearable controls-position="right" />%
          </form-item>
          <form-item title="超长模式触发概率" :pass="true" value="a_hundred_supermoderate">
            <el-input-number v-model="data.a_hundred_other_details.a_hundred_supermoderate" :min="0" :max="100"
              :precision="4" placeholder="超长模式触发概率" clearable controls-position="right" />%
          </form-item>
          <form-item title="飞机1.00倍坠毁概率" :pass="true" value="a_hundred_crash_rate">
            <el-input-number v-model="data.a_hundred_other_details.a_hundred_crash_rate" :min="0" :max="100"
              :precision="2" placeholder="飞机1.00倍坠毁概率" clearable controls-position="right" />%
          </form-item>
          <form-item title="正常模式玩家跑光后" :pass="true" value="a_hundred_normalmode" :subtract="!props.isDisableUser"
            @addItem="addNormalmode">
            <div class="flexWrap marginT5" v-for="(item, index) in data.normalmodeList" :key="index">
              倍数下限:
              <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="4"
                class="width150 marginR10" placeholder="倍数下限" clearable :controls="false" />
              倍数上限:
              <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="4"
                class="width150 marginR10" placeholder="倍数上限" clearable :controls="false" />
              下限百分比:
              <el-input-number v-model="item.percentMin" :min="0" :max="99999999999999999999" :precision="0"
                class="width150" placeholder="下限百分比" clearable :controls="false" />
              <span class="marginR10">%</span>
              上限百分比:
              <el-input-number v-model="item.percentMax" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginT5" placeholder="上限百分比" clearable :controls="false" />%
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceNormalmode(index)">-</div>
            </div>
          </form-item>
          <form-item title="超长模式玩家跑光随机倍数" :pass="true" value="a_hundred_supermode">
            <div class="flexWrap" v-for="(item, index) in data.supermodeList" :key="index">
              倍数下限:
              <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginR20" placeholder="倍数下限" clearable :controls="false" />
              倍数上限:
              <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0" class="width150"
                placeholder="倍数上限" clearable :controls="false" />
            </div>
          </form-item>
          <form-item title="机器人数量" :pass="true" value="a_robot_hundred_num" :subtract="!props.isDisableUser"
            @addItem="addRobotNum">
            下注模式:
            <el-input-number v-model="data.robotNumObject.type" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR10" placeholder="下注模式" clearable :controls="false" />
            机器人数量:
            <el-input-number v-model="data.robotNumObject.num" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR10" placeholder="机器人数量" clearable :controls="false" />
            百分比:
            <el-input-number v-model="data.robotNumObject.pattern" :min="0" :max="100" :precision="0" class="width150"
              placeholder="百分比" clearable :controls="false" /><span class="marginR10">%</span>
            下注额度模式:
            <el-input-number v-model="data.robotNumObject.patternNum" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR10" placeholder="下注额度模式" clearable :controls="false" />
            跳机模式:
            <el-input-number v-model="data.robotNumObject.jump" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR10 marginT5" placeholder="跳机模式" clearable :controls="false" />
            概率:
            <el-input-number v-model="data.robotNumObject.chance" :min="0" :max="100" :precision="0"
              class="width150 marginT5" placeholder="概率" clearable :controls="false" /><span class="marginR30">%</span>
            下注模式:
            <el-input-number v-model="data.robotNumObject.type2" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR10 marginT5" placeholder="下注模式" clearable :controls="false" />
            机器人数量:
            <el-input-number v-model="data.robotNumObject.num2" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginT5" placeholder="机器人数量" clearable :controls="false" />
            <div class="flexWrap marginT5" v-for="(item, index) in data.robotNumList" :key="index">
              下注模式:
              <el-input-number v-model="item.pattern" :min="0" :max="99999999999999999999" :precision="0" class="width120"
                placeholder="下注模式" clearable :controls="false" />
              下注额度模式:
              <el-input-number v-model="item.patternNum" :min="0" :max="99999999999999999999" :precision="0"
                class="width120" placeholder="下注额度模式" clearable :controls="false" />
              跳机模式:
              <el-input-number v-model="item.jump" :min="0" :max="99999999999999999999" :precision="0" class="width120"
                placeholder="跳机模式" clearable :controls="false" />
              概率:
              <el-input-number v-model="item.chance" :min="0" :max="100" :precision="0" class="width120" placeholder="概率"
                clearable :controls="false" />%
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceRobotNum(index)">-</div>
            </div>
          </form-item>
          <form-item title="头像昵称更换比例" :pass="true" value="a_robot_headname">
            <el-input-number v-model="data.a_hundred_other_details.a_robot_headname" :min="0" :max="100"
              placeholder="头像昵称更换比例" clearable controls-position="right" />%
          </form-item>
          <form-item title="有玩家未跳时坠机比例" :pass="true" value="a_hundred_crashproportion">
            <div class="flexWrap" v-for="(item, index) in data.crashproportionList" :key="index">
              下限百分比:
              <el-input-number v-model="item.min" :min="0" :max="100" :precision="0" class="width120" placeholder="下限百分比"
                clearable :controls="false" /><span class="marginR20">%</span>
              上限百分比:
              <el-input-number v-model="item.max" :min="0" :max="100" :precision="0" class="width120" placeholder="上限百分比"
                clearable :controls="false" />%
            </div>
          </form-item>
          <form-item title="机器人跳机" :pass="true" value="a_robot_leave" :subtract="!props.isDisableUser"
            @addItem="addRobotLeaveL">
            <div class="flexWrap margin5" v-for="(item, index) in data.robotLeaveList" :key="index">
              类型:
              <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="类型" clearable :controls="false" />
              权重:
              <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="权重" clearable :controls="false" />
              递增权重:
              <el-input-number v-model="item.increasing" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="递增权重" clearable :controls="false" />
              判定次数:
              <el-input-number v-model="item.num" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="判定次数" clearable :controls="false" />
              判定周期:
              <el-input-number v-model="item.time" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10 marginT5" placeholder="判定周期" clearable :controls="false" />
              下限Min(毫秒):
              <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10 marginT5" placeholder="下限Min(毫秒)" clearable :controls="false" />
              上限Max(毫秒):
              <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginT5" placeholder="上限Max(毫秒)" clearable :controls="false" />
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceRobotLeaveL(index)">-</div>
            </div>
          </form-item>
          <form-item title="游戏下注" :pass="true" value="a_hundred_stake">
            <div class="flexWrap margin5" v-for="(item, index) in data.gameStakeList" :key="index">
              刻度:
              <el-input-number v-model="item.scale" :min="0.0001" :max="99999999999999999999" :precision="4"
                class="width120 marginR10" placeholder="刻度" clearable :controls="false" />
              下注下限:
              <el-input-number v-model="item.min" :min="1" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="下注下限" clearable :controls="false" />
              下注上限:
              <el-input-number v-model="item.max" :min="1" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="下注上限" clearable :controls="false" />
              默认值:
              <el-input-number v-model="item.default" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR10" placeholder="默认值" clearable :controls="false" />
              赢上限额度:
              <el-input-number v-model="item.winMax" :min="0" :precision="0" :max="99999999999999999999"
                class="width150 marginR15 marginT5" placeholder="赢上限额度" clearable :controls="false" />
              快捷下注1:
              <el-input-number v-model="item.fast1" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginR15 marginT5" placeholder="快捷下注1" clearable :controls="false" />
              快捷下注2:
              <el-input-number v-model="item.fast2" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginR15 marginT5" placeholder="快捷下注2" clearable :controls="false" />
              快捷下注3:
              <el-input-number v-model="item.fast3" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginR15 marginT5" placeholder="快捷下注3" clearable :controls="false" />
              快捷下注4:
              <el-input-number v-model="item.fast4" :min="0" :max="99999999999999999999" :precision="0"
                class="width150 marginT5" placeholder="快捷下注4" clearable :controls="false" />
            </div>
          </form-item>
          <form-item title="初始水位" :pass="true" value="a_hundred_poolstart">
            <el-input-number v-model="data.a_hundred_other_details.a_hundred_poolstart" :min="-99999999999999999999"
              :max="99999999999999999999" placeholder="初始水位" clearable controls-position="right" />
          </form-item>
          <form-item title="水位配置" value="a_hundred_pool" :subtract="!props.isDisableUser" @addItem="addPool">
            <div class="flexWrap margin5" v-for="(item, index) in data.poolList" :key="index">
              水位下限:
              <el-input-number v-model="item.min" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
                class="width120 marginR5" placeholder="水位下限" clearable :controls="false" />
              水位上限:
              <el-input-number v-model="item.max" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
                class="width120 marginR5" placeholder="水位上限" clearable :controls="false" />
              权重:
              <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR5" placeholder="权重" clearable :controls="false" />
              押赢比例:
              <el-input-number v-model="item.winRatio" :min="0" :max="100" :precision="0" class="width120"
                placeholder="押赢比例" clearable :controls="false" /><span class="marginR5">%</span>
              押输比例:
              <el-input-number v-model="item.loseRatio" :min="0" :max="100" :precision="0" class="width120 marginT5"
                placeholder="押输比例" clearable :controls="false" /><span class="marginR5">%</span>
              输上限额度:
              <el-input-number v-model="item.lose" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
                class="width120 marginT5" placeholder="输上限额度" clearable :controls="false" />
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reducePool(index)">-</div>
            </div>
          </form-item>
          <form-item title="机器人下注" value="a_robot_hundred_stake" :subtract="!props.isDisableUser"
            @addItem="addRobotStake">
            <div class="flexWrap margin5" v-for="(item, index) in data.robotStakeList" :key="index">
              下注类型:
              <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR5" placeholder="下注类型" clearable :controls="false" />
              下注概率:
              <el-input-number v-model="item.chance" :min="0" :max="100" :precision="0" class="width120"
                placeholder="下注概率" clearable :controls="false" /><span class="marginR5">%</span>
              次数:
              <el-input-number v-model="item.num1" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR20" placeholder="次数One" clearable :controls="false" />
              比例:
              <el-input-number v-model="item.ratio1" :min="0" :max="100" :precision="0" class="width120"
                placeholder="比例One" clearable :controls="false" /><span class="marginR10">%</span>
              次数:
              <el-input-number v-model="item.num2" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginR12 marginT5" placeholder="次数Two" clearable :controls="false" />
              比例:
              <el-input-number v-model="item.ratio2" :min="0" :max="100" :precision="0" class="width120 marginT5"
                placeholder="比例Two" clearable :controls="false" /><span class="marginR12">%</span>
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceRobotStake(index)">-</div>
            </div>
          </form-item>
          <form-item title="下注额度" value="a_robot_hundred_stake_amount" :subtract="!props.isDisableUser"
            @addItem="addRobotAmount">
            <div class="flexWrap margin5" v-for="(item, index) in data.robotAmountList" :key="index"
              style="position: relative">
              额度类型:
              <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
                class="width120 marginB5" placeholder="额度类型" clearable :controls="false" />
              <div class="marginB5 flex" v-for="(second, two) in item.betAmount" :key="two">
                额度下限:
                <el-input-number v-model="second.min" :min="0" :max="99999999999999999999" :precision="4"
                  class="width130 marginR2" placeholder="额度下限" clearable :controls="false" />
                额度上限:
                <el-input-number v-model="second.max" :min="0" :max="99999999999999999999" :precision="4"
                  class="width130 marginR2" placeholder="额度上限" clearable :controls="false" />
                概率:
                <el-input-number v-model="second.chance" :min="0" :max="100" :precision="0" class="width110 marginR2"
                  placeholder="概率" clearable :controls="false" />%
                去尾概率:
                <el-input-number v-model="second.tailChance" :min="0" :max="100" :precision="0" class="width120"
                  placeholder="去尾概率" clearable :controls="false" />%
                <div class="add-btn marginL10" v-show="item.betAmountIndex == two && !props.isDisableUser"
                  @click="addStakeAmount(index, item)">+</div>
                <div class="reduce-btn reduce-btn_new marginL5" v-show="!props.isDisableUser"
                  @click="reduceStakeAmount(index, two, item)">-</div>
              </div>
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceRobotAmount(index)">-</div>
            </div>
          </form-item>
          <form-item title="下注手数" value="a_hundred_num" :subtract="!props.isDisableUser" @addItem="addRobotHundred">
            <div class="flexWrap margin5" v-for="(item, index) in data.robotHundredList" :key="index">
              时间起点:
              <el-input-number v-model="item.start" :min="0" :max="99999999999999999999" :precision="0"
                class="width110 marginR5" placeholder="时间起点" clearable :controls="false" />
              时间止点:
              <el-input-number v-model="item.end" :min="0" :max="99999999999999999999" :precision="0"
                class="width110 marginR5" placeholder="时间止点" clearable :controls="false" />
              随机下限:
              <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
                class="width110 marginR5" placeholder="随机下限" clearable :controls="false" />
              随机上限:
              <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0"
                class="width110 marginR5" placeholder="随机上限" clearable :controls="false" />
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceRobotHundred(index)">-</div>
            </div>
          </form-item>
          <form-item title="无人倍数" value="a_hundred_noperson" :subtract="!props.isDisableUser" @addItem="addNoperson">
            <div class="flexWrap margin5" v-for="(item, index) in data.nopersonList" :key="index">
              倍数下限:
              <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="4"
                class="width130 marginR15" placeholder="倍数下限" clearable :controls="false" />
              倍数上限:
              <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="4"
                class="width130 marginR15" placeholder="倍数上限" clearable :controls="false" />
              权重:
              <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0" class="width120"
                placeholder="权重" clearable :controls="false" />
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceNoperson(index)">-</div>
            </div>
          </form-item>
          <form-item title="下注展示" value="a_hundred_stake_show" :subtract="!props.isDisableUser" @addItem="addStakeShow">
            <div class="flexWrap margin5" v-for="(item, index) in data.stakeList" :key="index">
              种类权重:
              <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0" class="width130 marginR15"
                placeholder="权重" clearable :controls="false" />
              档位权重1:
              <el-input-number v-model="item.position1" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15" placeholder="下注档位权重1" clearable :controls="false" />
              档位权重2:
              <el-input-number v-model="item.position2" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15" placeholder="下注档位权重2" clearable :controls="false" />
              档位权重3:
              <el-input-number v-model="item.position3" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15 marginT5" placeholder="下注档位权重3" clearable :controls="false" />
              档位权重4:
              <el-input-number v-model="item.position4" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15 marginT5" placeholder="下注档位权重4" clearable :controls="false" />
              档位权重5:
              <el-input-number v-model="item.position5" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15 marginT5" placeholder="下注档位权重5" clearable :controls="false" />
              档位权重6:
              <el-input-number v-model="item.position6" :min="0" :max="99999999999999999999" :precision="0"
                class="width130 marginR15 marginT5" placeholder="下注档位权重6" clearable :controls="false" />
              <div v-show="!props.isDisableUser" class="reduce-btn marginL5" @click="reduceStakeShow(index)">-</div>
            </div>
          </form-item>
        </el-form>
      </div>
      <div v-else class="dialogMaxHeight" :class="props.isDisableUser ? 'disableUser' : ''">
        <el-form ref="ruleFormRef" :model="data" :inline="true" :scroll-to-error="true">
          <form-item title="飞机1.00倍坠毁概率" :pass="true" value="a_hundred_crash_rate">
            <el-input-number v-model="data.a_hundred_other_details.a_hundred_crash_rate" :min="0" :max="100"
              :precision="2" placeholder="飞机1.00倍坠毁概率" clearable controls-position="right" />%
          </form-item>
          <form-item title="利润率" :pass="true" value="a_hundred_profitmargin">
            <el-select v-model="data.a_hundred_other_details.a_hundred_profitmargin" filterable>
              <el-option v-show="item" v-for="item in 5" :label="item + '%'" :value="item" />
            </el-select>
            <span class="tipsText"> (玩家下注流水*利润率的值；建议值为3%至5%)</span>
          </form-item>
          <form-item title="游戏下注" :pass="true" value="a_hundred_stake">
            <div class="flexWrap margin5" v-for="(item, index) in data.gameStakeList" :key="index">
              <div class="xz-label">
                <div>额度:</div><el-input-number v-model="item.scale" :min="0.0001" :max="99999999999999999999" :precision="4"
                  class="selectWidth150 marginR10" placeholder="额度" clearable :controls="false" />
                <span class="tipsText"> (点击符号后增加或减少的值)</span>
              </div>
              <div class="xz-label">
                <div>下注下限:</div><el-input-number v-model="item.min" :min="1" :max="99999999999999999999" :precision="0"
                  class="selectWidth150 marginR10" placeholder="下注下限" clearable :controls="false" />
                <span class="tipsText">(下注最小值)</span>
              </div>
              <div class="xz-label">
                <div>下注上限:</div><el-input-number v-model="item.max" :min="1" :max="99999999999999999999" :precision="0"
                  class="selectWidth150 marginR10" placeholder="下注上限" clearable :controls="false" />
                <span class="tipsText">(下注最大值)</span>
              </div>
              <div class="xz-label">
                <div>默认值:</div><el-input-number v-model="item.default" :min="0" :max="99999999999999999999" :precision="0"
                  class="selectWidth150 marginR10" placeholder="默认值" clearable :controls="false" />
                <span class="tipsText">(进入游戏后的默认下注值)</span>
              </div>
              <div class="xz-label">
                <div>赢上限额度:</div><el-input-number v-model="item.winMax" :min="0" :precision="0"
                  :max="99999999999999999999" class="selectWidth150 marginR10" placeholder="赢上限额度" clearable
                  :controls="false" />
                <span class="tipsText">(游戏最大可赢取额度，当玩家下注*倍数＞该值时，只赔付玩家到该值)</span>
              </div>
              <div class="xz-label">
                <div>快捷下注1:</div><el-input-number v-model="item.fast1" :min="item.min" :max="item.max" :precision="0"
                  class="selectWidth150 marginR10" placeholder="快捷下注1" clearable :controls="false" />
                <span class="tipsText">(玩家可直接点击的下注额度)</span>
              </div>
              <div class="xz-label">
                <div>快捷下注2:</div><el-input-number v-model="item.fast2" :min="item.min" :max="item.max" :precision="0"
                  class="selectWidth150 marginR10" placeholder="快捷下注2" clearable :controls="false" />
                <span class="tipsText">(玩家可直接点击的下注额度)</span>
              </div>
              <div class="xz-label">
                <div>快捷下注3:</div><el-input-number v-model="item.fast3" :min="item.min" :max="item.max" :precision="0"
                  class="selectWidth150 marginR10" placeholder="快捷下注3" clearable :controls="false" />
                <span class="tipsText">(玩家可直接点击的下注额度)</span>
              </div>
              <div class="xz-label">
                <div>快捷下注4:</div><el-input-number v-model="item.fast4" :min="item.min" :max="item.max" :precision="0"
                  class="selectWidth150 marginR10" placeholder="快捷下注4" clearable :controls="false" />
                <span class="tipsText">(玩家可直接点击的下注额度)</span>
              </div>
            </div>
          </form-item>
        </el-form>
      </div>
    </div>
    <template #footer>
      <div class="dialog-footer" v-show="!props.isDisableUser">
        <el-button type="info" @click="onHideDetails">取 消</el-button>
        <el-button type="primary" @click="gameSet(ruleFormRef)" v-loading="indexStore.moduleLoading">确 定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import { getHundredConfig, editHundredConfig, getPool, editPool } from '@/api/game'
import GameHeaderInfo from '@/components/FormItem/GameHeaderInfo.vue'
import { BigWan, BigDiv, BigTimes, BigTimeWan } from '@/utils/math'
import { throttle, selectToLabel } from '@/utils/index'
import type {
  Normalmode,
  RobotNumObject,
  RobotNumList,
  RobotStake,
  GameStake,
  RobotLeave,
  RobotAmount,
  RobotHundred,
  Noperson,
  RobotPool
} from './gameType'

import { useStore } from '@/stores/index'
const indexStore = useStore()

const props = defineProps({
  show: {
    type: Boolean,
    default: () => {
      return false
    }
  },
  isDisableUser: {
    type: Boolean,
    default: () => {
      return false
    }
  },
  checkedItem: {
    type: Object,
    default: () => {
      return {}
    }
  }
})

watch(
  () => [props.checkedItem, props.show],
  async (value) => {
    if (value[0]) {
      Object.assign(data, props.checkedItem)
    }
    if (value[1]) {
      chooseOperator(props.checkedItem.agent_id, props.checkedItem.game_id) // 获取运营商配置
    }
  },
)

const data = reactive({
  id: 0,
  game_id: 0,
  agent_id: 0,
  game_name: '',
  operated_id: indexStore.agentArray[0]?.value,
  a_hundred_num: 0, // 房间最大人数
  a_hundred_pump: 0, // 抽水比例
  a_hundred_other_details: {
    a_hundred_crash_rate: 0,
    a_hundred_pool: '', // 水位配置(水位下限，水位上限，系统赢权重，赢押注比例，输押注比例，输上限额度......)
    a_hundred_poolstart: 0, // 初始水位
    a_hundred_profitmargin: 0, // 利润率
    a_hundred_supermoderate: 0, // 超长模式触发概率
    a_hundred_normalmode: '', // 正常模式玩家跑光后延长百分比(倍数下限，倍数上限，延长百分比下限，延长百分比上限......)*****
    a_hundred_supermode: '', // 超长模式玩家跑光后随机倍数(下限，上限)
    a_hundred_stake: '', // 游戏下注(刻度，最小值，最大值，默认值，最大赢取额度,快捷下注1，快捷下注2，快捷下注3，快捷下注4......)*****
    a_robot_hundred_num: '', // 机器人数量(机器人类型1，数量，下注模式，下注额度模式，跳机模式，概率;......)*****
    a_robot_hundred_stake: '', // 机器人下注(下注类型1；下注概率;次数1，比例;次数2，比例-......)*****
    a_robot_hundred_stake_amount: '', // 机器人下注额度(额度下限，额度上限，概率，去尾概率；.....) *****
    a_robot_leave: '', // 机器人跳机(跳机类型1，初始跳机权重，每次判定后递增权重，必走判定次数，判定周期【毫秒】，判定成功后延迟下限【毫秒】，判定成功后上限【毫秒】)*****
    a_robot_headname: 0, // 头像昵称更换比例
    a_hundred_noperson: '', // 无人倍数(随机倍数下限，随机倍数上限，权重；.....)
    a_hundred_crashproportion: '' // 有玩家未跳时坠机比例(坠机比例下限，坠机比例上限)
  },
  crashproportionList: [{ min: 0, max: 0 }], // 有玩家未跳时坠机比例
  supermodeList: [{ min: 0, max: 0 }], // 超长模式玩家跑光后随机倍数
  normalmodeList: [] as Normalmode[], // 正常模式玩家跑光后延长百分比
  robotNumObject: {} as RobotNumObject,
  robotNumList: [] as RobotNumList[], // 机器人数量
  gameStakeList: [] as GameStake[], // 游戏下注
  robotLeaveList: [] as RobotLeave[], //机器人跳机
  robotStakeList: [] as RobotStake[], // 机器人下注
  robotAmountList: [ // 机器人下注额度
    { type: 0, betAmount: [] as RobotAmount[], betAmountIndex: 0 }
  ],
  robotHundredList: [] as RobotHundred[], // 下注手数
  nopersonList: [] as Noperson[], // 无人倍数
  poolList: [] as RobotPool[], // 水位配置
  serverPoolList: [] as any[], // 服务器水位配置
  stakeList: [] as any[], //下注展示
  defaultBetMultiple: 1, //飞机下注额倍数 配置的额度上限值是默认飞机配置的多少倍【游戏下注上限】
  defaultBetStake: [] as any[], //默认-下注额度 配置的额度上限值是默认飞机配置的多少倍【游戏下注上限】
  defaultBetPool: [] as any[], //默认-水位配置 配置的额度上限值是默认飞机配置的多少倍【游戏下注上限】
  loading: false,
})

// 选择运营商
const chooseOperator = async (id: number, game_id: number) => {
  indexStore.setModuleLoading(true)
  // 水位
  if (data.agent_id && !indexStore.is_general_agent) {
    data.serverPoolList = []
    let agent = await getPool({ agent_id: props.checkedItem.agent_id, game_id: props.checkedItem.game_id });
    let keyData = Object.keys(agent.data);
    keyData.forEach((key:string)=>{
      data.serverPoolList.push({ label:selectToLabel(indexStore.serverNameList,key),value:BigWan(agent.data[key] ? agent.data[key] : 0),server:key  })
    })
  }
  // 游戏详情
  let res = await getHundredConfig({ agent_id: id, game_id: game_id });
  Object.assign(data, res.data)
  // 计算飞机下注额倍数
  let oldData = await getHundredConfig({ agent_id: 0, game_id: props.checkedItem.game_id }) as any;
  data.defaultBetMultiple = oldData.data.gameStakeList[0].max
  // 下注额度
  data.defaultBetStake =  oldData.data.robotAmountList
  // 水位配置
  data.defaultBetPool =  oldData.data.poolList
  nextTick(() => {
    indexStore.setModuleLoading(false)
  })
}

const ruleFormRef = ref<FormInstance>()
const rules = reactive<FormRules<typeof data>>({
  a_hundred_num: [{ required: true, message: '请输入房间最大人数', trigger: 'blur' }],
  a_hundred_pump: [{ required: true, message: '请输入抽水比例', trigger: 'blur' }]
})
const gameSet = throttle(async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate(async (valid, fields) => {
    if (valid) {
      // 游戏下注---默认值不能小于最小值
      if(data.gameStakeList[0].min > data.gameStakeList[0].default){
        return ElMessage.error('游戏下注默认值不能小于最小值')
      }
      // 游戏下注---默认值不能大于最大值
      if(data.gameStakeList[0].default > data.gameStakeList[0].max){
        return ElMessage.error('游戏下注默认值不能大于最大值')
      }
      // 游戏下注---最小值不能大于最大值的10分之一
      if(data.gameStakeList[0].min > BigDiv(data.gameStakeList[0].max,10)){
        return ElMessage.error('最小值不能大于最大值的10分之一')
      }
      // 游戏下注---配置的额度上限值是默认飞机配置的多少倍【游戏下注上限】
      let multiple = BigDiv(data.gameStakeList[0].max,data.defaultBetMultiple) //倍数
      // 下注额度
      data.defaultBetStake.forEach((item:any)=>{
        item.betAmount.forEach((second:any)=>{
          second.min = BigTimes(second.min,multiple)
          second.max = BigTimes(second.max,multiple)
        })
      })
      data.robotAmountList = data.defaultBetStake
      // 水位配置
      data.defaultBetPool.forEach((item:any)=>{
        item.min = BigTimes(item.min,multiple)
        item.max = BigTimes(item.max,multiple)
      })
      data.poolList = data.defaultBetPool 
      
      await editHundredConfig(data);
      if (data.agent_id && !indexStore.is_general_agent) {
        // 按服务器修改水位
        let pools= [] as number[],server=[] as any[];
        data.serverPoolList.forEach((item:any)=>{
          pools.push(BigTimeWan(item.value))
          server.push(item.server)
        })
        await editPool({
          agent_id: data.agent_id,
          game_id: data.game_id,
          pools: pools.join(','),
          server_ids: server.join(','),
        })
      }
      ElMessage.success('修改成功')
      emit('onHideDetails', true)
    }
  })
}, 5000)

// 正常模式玩家跑光后延长百分比
const addNormalmode = () => {
  data.normalmodeList.push({ min: 0, max: 0, percentMin: 0, percentMax: 0 })
}
const reduceNormalmode = (index: number) => {
  data.normalmodeList.splice(index, 1)
}

// 机器人数量
const addRobotNum = () => {
  data.robotNumList.push({ pattern: 0, patternNum: 0, jump: 0, chance: 0 })
}
const reduceRobotNum = (index: number) => {
  data.robotNumList.splice(index, 1)
}

// 机器人下注
const addRobotStake = () => {
  data.robotStakeList.push({ type: 0, chance: 1, num1: 0, ratio1: 1, num2: 0, ratio2: 1 })
}
const reduceRobotStake = (index: number) => {
  data.robotStakeList.splice(index, 1)
}

// 机器人跳机
const addRobotLeaveL = () => {
  data.robotLeaveList.push({ type: 0, weight: 0, increasing: 0, num: 0, time: 0, min: 0, max: 0 })
}
const reduceRobotLeaveL = (index: number) => {
  data.robotLeaveList.splice(index, 1)
}

// 下注额度
const addRobotAmount = () => {
  if (!data.robotAmountList.length) {
    data.robotAmountList.push({ type: 1, betAmount: [{ min: 0, max: 0, chance: 0, tailChance: 0 }], betAmountIndex: 0 })
  } else {
    data.robotAmountList.push({ type: data.robotAmountList[data.robotAmountList.length - 1].type + 1, betAmount: [{ min: 0, max: 0, chance: 0, tailChance: 0 }], betAmountIndex: 0 })
  }
}
const reduceRobotAmount = (index: number) => {
  data.robotAmountList.splice(index, 1)
}
const addStakeAmount = (index: number, item: any) => {
  item.betAmountIndex++
  data.robotAmountList[index].betAmount.push({ min: 0, max: 0, chance: 0, tailChance: 0 })
}
const reduceStakeAmount = (index: number, two: number, item: any) => {
  item.betAmountIndex--
  data.robotAmountList[index].betAmount.splice(two, 1)
}


// 下注手数
const addRobotHundred = () => {
  data.robotHundredList.push({ start: 0, end: 1, min: 0, max: 1 })
}
const reduceRobotHundred = (index: number) => {
  data.robotHundredList.splice(index, 1)
}

// 无人倍数
const addNoperson = () => {
  data.nopersonList.push({ min: 0, max: 1, weight: 0 })
}
const reduceNoperson = (index: number) => {
  data.nopersonList.splice(index, 1)
}

// 下注展示
const addStakeShow = () => {
  data.stakeList.push({ type: 0,
    position1: 0,
    position2: 0,
    position3: 0,
    position4: 0,
    position5: 0,
    position6: 0 
  })
}
const reduceStakeShow= (index: number) => {
  data.stakeList.splice(index, 1)
}

// 水位配置
const addPool = () => {
  data.poolList.push({ min: 0, max: 1, weight: 0, winRatio: 0, loseRatio: 0, lose: 0 })
}
const reducePool = (index: number) => {
  data.poolList.splice(index, 1)
}

// 重置
const emit = defineEmits(['onHideDetails'])
const onHideDetails = () => {
  data.serverPoolList = []
  emit('onHideDetails', false)
}
</script>

<style scoped lang="scss">
.add-btn {
  position: absolute;
  left: 185px;
  top: 8px;
  background-color: green;
}

.reduce-btn_new {
  background-color: #e6a23c;
}

.xz-label {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  padding: 15px 0 5px 0;
  border-bottom: 1px solid var(--el-border-color-lighter);

  div {
    width: 100px;
  }
}
</style>